package com.peng._05weibo.mapper;

import com.peng._05weibo.pojo.entity.User;
import com.peng._05weibo.pojo.vo.UserVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author peng
 * @Date 2024-04-23 11:37
 */
public interface UserMapper {
    /**
     * 新增用户
     * @param user 用户对象
     * @return 修改的行数
     */
    @Insert("insert into user(username, password, nickname, created) " +
            "values (#{username}, #{password}, #{nickname}, #{created})")
    int insertUser(User user);

    /**
     * 注册功能
     * 根据用户名查询用户，校验用户名是否已占用
     * 查询什么数据都可以
     * @param username 用户名
     * @return UserVO
     */
    @Select("select id, password, nickname " +
            "from user " +
            "where username = #{username}")
    UserVO selectUserByUsername(String username);
}
